<?php
/**
 * 通过请求参数设置 AppLocale
 *
 * Author: Zeon
 * Date: 2017/11/20
 * Created by Panxsoft.
 */
namespace App\Http\Middleware;

use App\Services\Locale\Language;
use App\Services\MobileApp\AppEnv;
use Closure;
use Illuminate\Http\Request;

class AppLocale
{
    /**
     *
     * @param Request $request
     * @param Closure $next
     * @return mixed
     * @throws \Exception
     */
    public function handle(Request $request, Closure $next)
    {
        // 设置语言
        Language::setAppLocale(AppEnv::language()->code);

        return $next($request);
    }
}